﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace FurnitureSystem
{
    public partial class frmThemLoaiSP : Form
    {
        SqlCommand cmd;
        SqlConnection conn;
        SqlDataReader dr;
        public frmThemLoaiSP()
        {
            InitializeComponent();
        }

        private void BtnThem_Click(object sender, EventArgs e)
        {
            if (txtIDLoai.Text == "" || txtTenLoai.Text == "")
            {
                MessageBox.Show("Vui lòng điền đầy đủ thông tin");
            }
            else
            {
                conn = connect.Getconect();
                conn.Open();
                string sql = "insert into Type values ('" + Int32.Parse(txtIDLoai.Text) + "','" + txtTenLoai.Text + "')";
                cmd = new SqlCommand(sql, conn);
                dr = cmd.ExecuteReader();
                MessageBox.Show("Thêm thành công!");
                conn.Close();
                txtIDLoai.Text = "";
                txtTenLoai.Text = "";
            }
        }

        private void BtnThoat_Click(object sender, EventArgs e)
        {
            this.Hide();
        }
    }
}
